import {contain} from "@/common/js/utils";

const state = {
    likes: [],
    recent: []
}

const getters = {
    likes: state => state.likes,
    recent: state => state.recent
}

const mutations = {
    addLike: (state,song) => {
        if(!contain(state.likes,song))
           state.likes.unshift(song)
    },
    removeLike: (state,song) => state.likes = state.likes.filter(item => item !== song),
    addRecent: (state,song) => {
        if(!contain(state.recent,song))
            state.recent.unshift(song)
    }
}

const actions = {

}

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
}
